<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="probiz" tagdir="/WEB-INF/tags/probiz"%>
<%@ taglib prefix="product" tagdir="/WEB-INF/tags/product"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<probiz:pageHeading entityName="${productReview.productReviewName}"
	entityHeadingKey="productReviewDetail.heading" />
<content tag="buttons">
<c:if test="${productReview.productReviewId!=null}">
	<probiz:iconBtn btnType="delete" onclick="return fnDoDelete(this);" />
</c:if>
<probiz:iconBtn btnType="back"
	onclick="return fnDoCancelForm(this);" />
</content>
<probiz:showBindErrors bindPath="productReview.*" />
<form id="productReview" class="mainForm"
	action="${ctxPath}/catalog/productReview.html" method="post"
	onsubmit="return validateProductReview(this);">
	<input type="hidden" name="productReviewId"
		value="${productReview.productReviewId}" />
</form>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
	class="com_modi_table">
	<tr>
		<td colspan="4" class="title">
			<fmt:message key="productReviewDetail.heading" />
		</td>
	</tr>
	<tr>
		<th width="15%">
			<StoreAdmin:label key="productReview.subject" />
		</th>
		<td width="35%">
			<c:out value="${productReview.subject}" />
		</td>
		<th width="15%">
			<StoreAdmin:label key="productReview.productId" />
		</th>
		<td width="35%">
			${productReview.product.productName}
		</td>
	</tr>
	<tr>
		<th>
			<StoreAdmin:label key="productReview.message" ignoreValidation="true" />
		</th>
		<td>
			<spring:bind path="productReview.message">
				<textarea rows="5" style="width: 300px" class="form-inputbox"
					readonly="readonly">${status.value}
				</textarea>
				<span class="fieldError">${status.errorMessage}</span>
			</spring:bind>
		</td>
		<th colspan="2">
			<table width="100%" border="0" cellspacing="0" cellpadding="0"
				class="no-border no-margin">
				<tr>
					<th width="30%">
						<fmt:message key="productReview.rate" />
						:
					</th>
					<td width="70%" style="text-align: left; padding: 5px;">
						<product:ratingStar value="${productRateValue.rateValue}" />
					</td>
				</tr>
				<c:forEach items="${productReview.productRateValues}"
					var="productRateValue">
					<tr>
						<th>
							${productRateValue.productRateItem.rateName}:
						</th>
						<td style="text-align: left; padding: 5px;">
							<product:ratingStar value="${productRateValue.rateValue}" />
						</td>
					</tr>
				</c:forEach>
			</table>
		</th>
	</tr>
	<tr>

		<c:choose>
			<c:when test="${productReview.reviewUser.appuserId!=-2}">
				<%--不能赠送积分给匿名用户--%>
				<th style="line-height: 18px;">
					<StoreAdmin:label key="productReview.givenPoint" />
				</th>
				<td style="vertical-align:top;">
					<c:choose>
						<c:when test="${empty productReview.givenTime}">
							<form
								action="${ctxPath}/catalog/productReview.html?doAction=save"
								method="post">
								<select name="givenPoint" id="givenPoint" class="form-inputbox">
									<c:forEach items="${productReviewGivenPoints}"
										var="productReviewGivenPoint">
										<option value="${productReviewGivenPoint}">
											${productReviewGivenPoint}
										</option>
									</c:forEach>
								</select>
								&nbsp;&nbsp;
								<input type="submit" class="admin-btn"
									value="<fmt:message key='productReview.givenPoint'/>" />
								<input type="hidden" name="productReviewId"
									value="${productReview.productReviewId}" />
								<input type="hidden" name="reviewUserId" id="reviewUserId"
									value="${productReview.reviewUser.appuserId}" />
							</form>
						</c:when>
						<c:otherwise>
							${productReview.givenPoint}
					<br />
							<StoreAdmin:label key="productReview.grantor" />
					${productReview.grantor.username}
					<br />
							<StoreAdmin:label key="productReview.givenTime" />
							<fmt:formatDate value="${productReview.givenTime}"
								pattern="yyyy-MM-dd hh:mm:ss" />
						</c:otherwise>
					</c:choose>
				</td>
			</c:when>
			<c:otherwise>
				<th style="line-height: 18px;">
				</th>
				<td style="vertical-align:top;">

				</td>
			</c:otherwise>
		</c:choose>

		<th width="15%" style="line-height: 18px;">
			<StoreAdmin:label key="productReview.status"
				ignoreValidation="${productReview.status==1}" />
		</th>
		<td width="35%" style="vertical-align:top;">
			<c:choose>
				<c:when test="${productReview.status!=1}">
					<form
						action="${ctxPath}/catalog/productReview.html?doAction=active"
						method="post">
						<fmt:message key="productReview.status_${productReview.status}" />
						&nbsp;&nbsp;
						<input type="submit" class="admin-btn"
							value="<fmt:message key='productReview.active'/>" />
						<input type="hidden" name="productReviewId"
							value="${productReview.productReviewId}" />
					</form>
				</c:when>
				<c:otherwise>
					<fmt:message key="productReview.status_${productReview.status}" />
				</c:otherwise>
			</c:choose>
		</td>


	</tr>


	<tr>
		<th width="15%">
			<StoreAdmin:label key="productReview.customerName" />
		</th>
		<td width="35%">
			<c:choose>
				<c:when test="${productReview.reviewUser.appuserId==-2}">
					<c:out value="${productReview.customerName}" />(<fmt:message
						key="productReview.reviewUser.anonymous" />)
					</c:when>
				<c:otherwise>
						${productReview.reviewUser.username}
					</c:otherwise>
			</c:choose>
		</td>
		<th width="15%">
			<StoreAdmin:label key="productReview.remoteIp"
				ignoreValidation="true" />
		</th>
		<td width="35%">
			${productReview.remoteIp}
		</td>
	</tr>
	<tr>
		<th width="15%">
			<StoreAdmin:label key="productReview.createTime" />
		</th>
		<td width="35%">
			<fmt:formatDate value="${productReview.createTime}"
				pattern="yyyy-MM-dd hh:mm:ss" />
		</td>
		<th width="15%">
			<StoreAdmin:label key="productReview.updateTime" />
		</th>
		<td width="35%">
			<fmt:formatDate value="${productReview.updateTime}"
				pattern="yyyy-MM-dd hh:mm:ss" />
		</td>
	</tr>
</table>
<div id="divReviewReplyList"></div>
<div class="box-content-wrap">
	<div class="box-content">
		<div class="content">
			<table width="100%" border="0" cellspacing="0" cellpadding="0"
				class="com_modi_table" id="reviewReplyForm">
				<tr>
					<th width="35%">
						<fmt:message key="productReview.reply.message" />
					</th>
					<td width="65%">
						<span><textarea rows="5" style="width: 350px" name="message"
							id="message" class="form-inputbox"></textarea></span>
						<input type="hidden" name="productId"
							value="${productReview.productId}" />
						<probiz:probizBtn btnType="common" inputType="button"
							inputName="add" onclick="fnSaveReply();"
							commonBtnValueKey="button.add" />
					</td>
				</tr>
			</table>
		</div>
	</div>
</div>
<v:javascript formName="productReview" staticJavascript="false" />
<script type="text/javascript" defer>
function fnGetReviewReplyList(){
	$j("#divReviewReplyList").load(__ctxPath+"/catalog/productReview/dialog.html?doAction=listReply&productReviewId=${productReview.productReviewId}");
	
}
function fnSaveReply(){
    if(validateForm($j("#reviewReplyForm").get(0))){
    	var paramData=$j("#reviewReplyForm :input").serializeArray();
	$j.post(__ctxPath+"/catalog/productReview/dialog.html?doAction=saveReply&reviewId=${productReview.productReviewId}",paramData,function(){fnGetReviewReplyList();$j("#message").val("");});
    }
}

function fnDeleteReply(productReviewId){
    if (!confirm('<fmt:message key="catalog.review.delete" />'))
    {
        return;
    }
    $j.post(__ctxPath+"/catalog/productReview/dialog.html?doAction=deleteReply&productReviewId="+productReviewId,fnGetReviewReplyList);
}


$j(document).ready(function(){
	fnGetReviewReplyList();
});
</script>
